package com.njtoyo.taxi.admin.rest.controller.business;

import cn.hutool.core.lang.Dict;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.njtoyo.taxi.admin.aop.PassToken;
import com.njtoyo.taxi.admin.rest.wrapper.business.simple_call.SimpleCallDiagramQueryWrapper;
import com.njtoyo.taxi.admin.service.business.SimpleCallDiagramService;
import com.njtoyo.taxi.entity.backend.AdminUser;
import com.taxi.entity.common.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("business/simple_call/diagram")
public class SimpleCallDiagramController {

    @Autowired
    SimpleCallDiagramService simpleCallDiagramService;


    @GetMapping("/getCustomeServiceCallPage")
    public RestResult getCustomeServiceCallPage(SimpleCallDiagramQueryWrapper wrapper,@ModelAttribute("admin") AdminUser adminUser) {
        return simpleCallDiagramService.getCallList(wrapper,adminUser);
    }


    @GetMapping("/getOverview")
    public RestResult getOverview(@ModelAttribute("admin") AdminUser adminUser) {
        return simpleCallDiagramService.getOverview(adminUser);
    }


    @GetMapping("/chartData")
    public RestResult chartData(@ModelAttribute("admin") AdminUser adminUser) {
        return simpleCallDiagramService.chartData(adminUser);
    }

    @GetMapping("/getCancelChartData")
    public RestResult getCancelChartData(@ModelAttribute("admin") AdminUser adminUser) {
        return simpleCallDiagramService.getCancelChartData(adminUser);
    }

    @GetMapping("/getAllUser")
    public RestResult getAllUser(@ModelAttribute("admin") AdminUser adminUser) {
        return simpleCallDiagramService.getAllUser(adminUser);
    }


    @PostMapping("/saveCustomerService")
    public RestResult saveCustomerService(@RequestBody Dict params) {
        String ids = MapUtil.getStr(params, "ids");
        if (StrUtil.isBlank(ids)) {
            return RestResult.failed("最少需要设置一个客服");
        }
        return simpleCallDiagramService.saveCustomerService(ids);
    }


    @GetMapping("/getCustomeService")
    public RestResult getCustomeService(@ModelAttribute("admin") AdminUser adminUser) {
        return simpleCallDiagramService.getCustomeService(adminUser);
    }


}
